function wrapContent(content, max_characters) {
	if (content.length <= max_characters)
		return content;
		
	var content_truncated = content.substring(0, max_characters);
	
	last_ocurrence_pos = content_truncated.lastIndexOf(' ');
	
	if (last_ocurrence_pos > 0) {
		return content.substring(0, last_ocurrence_pos) + ' ...';
	}
	
	return content_truncated + '...';
}

function wrapContentToHeight(content_html_id, max_heigth) {
	var contentTd = document.getElementById(content_html_id);

	while(contentTd.offsetHeight > max_heigth) {
		var str = contentTd.innerHTML;
		// Check to avoid breaking html tags
		if ( str.substr(contentTd.innerHTML.length - 6).indexOf('>') == -1 ) {
			str = str.substr(0, contentTd.innerHTML.length - 6);
		} else {
			str = str.substr(0, str.lastIndexOf('<'));
		}

		str = str + "...";

		contentTd.innerHTML = str;
	}
}
